import java.lang.reflect.Array;
import java.util.*;

public class Test {

    public static List REMOVE(List<String> list){

        List<String> map = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (!map.contains(list.get(i))){
                map.add(list.get(i));//不存在才可以存进map中
            }
        }
        return map;
    }
    public static void main1(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("apple");
        list.add("banana");
        list.add("apple");
        list.add("orange");
        list.add("banana");
        list.add("grape");
        list.add("grape");
        System.out.println(REMOVE(list));


    }

    public static Map<String,Integer> cotain(List<String> list){

        Map<String,Integer> countMap = new HashMap<>();
        for ( String tmp: list) {
            countMap.put(tmp,countMap.getOrDefault(tmp,0)+1);

        }
        return countMap;
    }

    public static void main2(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("apple");
        list.add("banana");
        list.add("apple");
        list.add("orange");
        list.add("banana");
        list.add("grape");
        list.add("grape");
        System.out.println("水果出现的数量:" + cotain(list));
    }

    public static Map<String,List<String>> spilt(List<String> list){

        List<String> num = new ArrayList<>();
        List<String> str = new ArrayList<>();

        for (String s:list) {
            if(s.matches("\\d+")){
                num.add(s);
            }else if(s.matches("[a-zA-Z]+")){
                str.add(s);
            }
        }
        Map<String , List<String>> result = new HashMap<>();
        result.put("数字列表" , num);
        result.put("字母列表" , str);
        return result;
    }

    public static void main(String[] args) {
        List<String > list = Arrays.asList("123","abc","456","def","789","ghi");
        System.out.println(spilt(list));



    }
    private static int partition(int[] array, int left, int right) {
        int i = left;
        int j = right;
        int pivot = array[left];
        while (i < j) {
            while (i < j && array[j] >= pivot) {
                j--;
            }
            while (i < j && array[i] <= pivot) {
                i++;
            }
            swap(array, i, j);
        }
        swap(array, i, left);
        return i;
    }
    public static int gcd(int a,int b){ // 不需要判断a和b的大小
        while(b>0){
            a%=b;b^=a;a^=b;b^=a;
//           while(b^=a^=b^=a%=b);
        }
        return a;
//        return (a % b == 0) ? b : gcd(b, a%b);
    }

    public static void cinInit(){
        cin.wordChars('a', 'z');
        cin.wordChars('A', 'Z');
        cin.wordChars(128 + 32, 255);
        cin.whitespaceChars(0, ' ');
        cin.commentChar('/');
        cin.quoteChar('"');
        cin.quoteChar('\'');
        cin.parseNumbers(); //可单独使用还原数字
    }
    public static int nextInt() throws Exception {
        cin.nextToken();
        return (int) cin.nval;
    }
    public static long nextLong() throws Exception {
        cin.nextToken();
        return (long) cin.nval;
    }
    public static double nextDouble() throws Exception {
        cin.nextToken();
        return cin.nval;
    }
    public static String nextString() throws Exception {
        cin.nextToken();
        return cin.sval;
    }
    public static void closeAll() throws Exception {
        cout.close();
        in.close();
        out.close();
    }

    public static void heapSort(int[] array) {
        int n = array.length;
        for (int i = n / 2 - 1; i >= 0; i--) {
            heapify(array, n, i);
        }
        for (int i = n - 1; i >= 0; i--) {
            int temp = array[0];
            array[0] = array[i];
            array[i] = temp;
            heapify(array, i, 0);
        }
    }

    private static void heapify(int[] array, int n, int i) {
        int largest = i;
        int left = 2 * i + 1;
        int right = 2 * i + 2;
        if (left < n && array[left] > array[largest]) {
            largest = left;
        }
        if (right < n && array[right] > array[largest]) {
            largest = right;
        }
        if (largest != i) {
            int swap = array[i];
            array[i] = array[largest];
            array[largest] = swap;
            heapify(array, n, largest);
        }
    }
    public static void shellSort(int[] array) {
        int n = array.length;
        for (int gap = n / 2; gap > 0; gap /= 2) {
            for (int i = gap; i < n; i++) {
                int temp = array[i];
                int j;
                for (j = i; j >= gap && array[j - gap] > temp; j -= gap) {
                    array[j] = array[j - gap];
                }
                array[j] = temp;
            }
        }
    }





}
